"""
Dinky任务相关模式
"""

from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime


class DinkyTaskBase(BaseModel):
    """Dinky任务基础模式"""
    name: str
    statement: Optional[str] = None
    type: Optional[str] = None
    enabled: bool = True
    note: Optional[str] = None


class DinkyTaskResponse(BaseModel):
    """Dinky任务响应模式"""
    id: int
    name: str
    statement: Optional[str] = None
    type: Optional[str] = None
    enabled: bool
    note: Optional[str] = None
    create_time: Optional[datetime] = None
    update_time: Optional[datetime] = None
    
    class Config:
        from_attributes = True


class DinkyTaskList(BaseModel):
    """Dinky任务列表模式"""
    tasks: List[DinkyTaskResponse]
    total: int


class TaskStatementRequest(BaseModel):
    """任务SQL语句请求模式"""
    task_id: int
    
    
class TaskStatementResponse(BaseModel):
    """任务SQL语句响应模式"""
    task_id: int
    task_name: str
    statement: Optional[str] = None
    statement_length: int = 0
    has_statement: bool = False
